package com.devilvan.betrice.opgg.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.devilvan.betrice.common.BasePo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author Evad.Wu
 * @Description OPGG-英雄位置信息 映射
 * @date 2022-10-04
 */
@Setter
@Getter
@ToString(exclude = {"opggChampionMetaPo", "opggPositionRolePoList", "opggPositionCounterPoList"})
@NoArgsConstructor
@Accessors(chain = true)
@TableName(value = "OPGG_CHAMPION_POSITION")

@Entity
@Table(name = "OPGG_CHAMPION_POSITION")
@DynamicInsert
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "OPGG-英雄位置信息 映射")
public class OpggChampionPositionPo extends BasePo implements Serializable {
    @Serial
    private static final long serialVersionUID = 2285165516236149345L;
    @Schema(description = "HEADER的ID")
    @TableField(value = "HID")
    @Column(name = "HID", columnDefinition = "BIGINT(19) NOT NULL COMMENT 'HEADER的ID'")
    private Long hid;
    @Schema(description = "英雄ID")
    @TableField(value = "CHAMPION_ID")
    @Column(name = "CHAMPION_ID", columnDefinition = "BIGINT(19) NOT NULL COMMENT '英雄ID'")
    private Long championId;
    @Schema(description = "英雄称号")
    @TableField(value = "NAME")
    @Column(name = "NAME", columnDefinition = "VARCHAR(32) NOT NULL COMMENT '英雄称号'")
    private String name;
    @Schema(description = "英雄名称")
    @TableField(value = "KEY_NAME")
    @Column(name = "KEY_NAME", columnDefinition = "VARCHAR(16) NOT NULL COMMENT '英雄名称'")
    private String keyName;
    @Schema(description = "位置")
    @TableField(value = "POSITION")
    @Column(name = "POSITION", columnDefinition = "VARCHAR(8) COMMENT '位置'")
    private String position;
    @Schema(description = "胜率")
    @TableField(value = "WIN_RATE")
    @Column(name = "WIN_RATE", columnDefinition = "DECIMAL(12) COMMENT '胜率'")
    private BigDecimal winRate;
    @Schema(description = "出场率")
    @TableField(value = "PICK_RATE")
    @Column(name = "PICK_RATE", columnDefinition = "DECIMAL(12) COMMENT '出场率'")
    private BigDecimal pickRate;
    @Schema(description = "该位置登场率")
    @TableField(value = "ROLE_RATE")
    @Column(name = "ROLE_RATE", columnDefinition = "DECIMAL(12) COMMENT '该位置登场率'")
    private BigDecimal roleRate;
    @Schema(description = "禁用率")
    @TableField(value = "BAN_RATE")
    @Column(name = "BAN_RATE", columnDefinition = "DECIMAL(12) COMMENT '禁用率'")
    private BigDecimal banRate;
    @Schema(description = "KDA")
    @TableField(value = "KDA")
    @Column(name = "KDA", columnDefinition = "DECIMAL(12) COMMENT 'KDA'")
    private BigDecimal kda;
    @Schema(description = "梯队")
    @TableField(value = "TIER")
    @Column(name = "TIER", columnDefinition = "INT(10) COMMENT '梯队'")
    private Integer tier;
    @Schema(description = "排名")
    @TableField(value = "POSITION_RANK")
    @Column(name = "POSITION_RANK", columnDefinition = "INT(10) COMMENT '排名'")
    private Integer positionRank;
    @Schema(description = "上一次记录排名")
    @TableField(value = "RANK_PREV")
    @Column(name = "RANK_PREV", columnDefinition = "INT(10) COMMENT '上一次记录排名'")
    private Integer rankPrev;
    @Schema(description = "上一版本排名")
    @TableField(value = "RAND_PREV_PATCH")
    @Column(name = "RAND_PREV_PATCH", columnDefinition = "INT(10) COMMENT '上一版本排名'")
    private Integer randPrevPatch;

    @Schema(description = "英雄信息")
    @ManyToOne(targetEntity = OpggChampionMetaPo.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumns(value = {
            @JoinColumn(name = "HID", referencedColumnName = "HID", insertable = false, updatable = false),
            @JoinColumn(name = "CHAMPION_ID", referencedColumnName = "CHAMPION_ID", insertable = false, updatable = false)
    })
    private OpggChampionMetaPo opggChampionMetaPo;
    @Schema(description = "英雄位置-角色定位信息")
    @OneToMany(targetEntity = OpggPositionRolePo.class, mappedBy = "opggChampionPositionPo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OpggPositionRolePo> opggPositionRolePoList;
    @Schema(description = "英雄位置-英雄克制信息")
    @OneToMany(targetEntity = OpggPositionCounterPo.class, mappedBy = "opggChampionPositionPo", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<OpggPositionCounterPo> opggPositionCounterPoList;
}
